<?php 
/*
 * @version :  2013-3-18
* @project :  account-system
* @Author  :  Allen
* @e-mail  :  shulei@maszy.cn
* @des		:  修改密码
*/
/**
 * 调用配置文件，并连接数据库
*/
require_once (dirname(__FILE__)."/../../config/config.php");
if(empty($_SESSION['lang'])){
    $_SESSION['lang']= "cn";
}elseif($_GET['lang'] == "en"){
    $_SESSION['lang']= "en";
}elseif($_GET['lang'] == "cn"){
      $_SESSION['lang']= "cn";
}
/**
 根据method 调用 代码块
*/
$userName = $_REQUEST['userName'];
$time = base64_decode($_REQUEST['t']);
if((date("YmdHis") - $time) >= 1000000){
	$errorTxt.='此链接已经失效';
	$enErrorTxt.='This link is invalid.';
	$flag='1';
}
$method = $_REQUEST['method'];
if($method == 'setPass'){
	/**
		获取页面提交参数
	 */
	$userName = base64_decode($_REQUEST['userName']);
	$password = $_REQUEST['password'];
	$password1 = $_REQUEST['password1'];
	$flag = $_REQUEST['flag'];
	/**
	 *	设置返回成功和失败的信息
	 */
	$errorTxt.='';
	$enErrorTxt.='';
	$successTxt.='';

	if(!empty($password)){
		if(!empty($password1)){
			if(strlen($password) >= 6 && strlen($password1) >= 6){
				$number = strcmp($password,$password1);
				if($number == 0){
					$sql="update zy_user set password='".$password."' where user_name='".$userName."' and isdelete=0";
					$rs = mysql_query($sql) or die(mysql_error());
					if($rs > 0){
						$successTxt.='密码修改成功!';
						header("location:returnUpdatePassInfo.php");
					}else{
						$errorTxt.='密码修改失败!';
						$enErrorTxt.='Password change failed';
					}
				}else{
					$errorTxt.='两次密码输入不一致!';
					$enErrorTxt.='Two password input does not match!';
				}
			}else{
				$errorTxt.='密码的长度不能小于6位!';
				$enErrorTxt.='The length of the password can\'t less than 6!';
			}
		}else{
			$errorTxt.='请输入重复密码!';
			$enErrorTxt.='Please enter the repeated password!';
		}
	}else{
		$errorTxt.='请输入密码!';
		$enErrorTxt.='Please enter a password!';
	}
}


?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>NetCube</title>
  <meta name="viewport" content="width=device-width,initial-scale=1" />

    <link rel="stylesheet" type="text/css" href="style/reset.css" /> 
    <link rel="stylesheet" type="text/css" href="style/root.css" /> 
    
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/toogle.js"></script>
    
</head>
<body>


	
    <!-- start header -->
    	<div id="header">
         <a href="#"><img src="img/logo.png" width="77" height="24" alt="logo" class="logo" /></a>
         	<a href="index.php" class="button back"><img src="img/back-button.png" width="15" height="16" alt="icon" /></a>
        <div class="clear"></div>
        </div>
    <!-- end header -->
    
    <!-- start page -->
    <div class="page">
    
    		
            <div class="simplebox">
            	<h1 class="titleh"><?php  if($_SESSION['lang'] =='en'){ echo "Change Password";}else{ echo "修改密码";}?></h1>
                <div class="content">
                	
                  <form id="form12" name="form1" method="post" action="updatePassword.php?method=setPass">
                  
                     <!--提示框-->
                    <?php if(!empty($errorTxt)){ ?>
                    <div class="albox errorbox" >
                      <b><?php  if($_SESSION['lang'] == 'en'){echo 'Input error:';}else{echo '输入错误：';}?></b>
                      <?php 
		                      if($_SESSION['lang'] == 'en'){
		                      	echo $enErrorTxt;
		                      }else{
		                      	echo $errorTxt;
		                      }
						}else{ ?>   
                       <div class="albox errorbox" style="display:none;">
                      <?php } ?>
                      <a href="#" class="close tips" title="close">close</a>
                    </div>
                  		
                    
                  		
                    <div class="form-line">
                   	  <label class="st-label"><?php  if($_SESSION['lang'] =='en'){ echo "New Password";}else{ echo "新密码";}?></label>
                   	  <?php if($flag == '1'){?>
                   	  	<input type="password" id="password" name="password" readonly="readonly" style=" width:80%;" />
                   	  <?php }else{ ?>
	                      <input type="password" id="password" name="password" style=" width:80%;" />
	                      <input type="hidden" id="userName" name="userName" style=" width:80%;" value="<?php echo $userName; ?>" />
	                      <input type="hidden" id="flag" name="flag" style=" width:80%;" value="<?php echo $flag; ?>" />
                      <?php }?>
                    </div>
                    
                    <div class="form-line">
                   	  <label class="st-label"><?php  if($_SESSION['lang'] =='en'){ echo "Confirm New Password";}else{ echo "确认新密码";}?></label>
                   	   <?php if($flag == '1'){?>
                   	  	 <input type="password" class="Textbox" id="password1" name="password1" readonly="readonly" style=" width:80%;"/>
                   	   <?php }else{ ?>
                     		<input type="password" class="Textbox" id="password1" name="password1" style=" width:80%;"/>
                      <?php }?>
                    </div>
                    
                  	
                    <div class="clear"></div>
                    

                    
                    <div class="form-line">
                    <input type="submit" id="sendsub" name="sendsub" value="<?php if($_SESSION['lang'] == 'en'){echo 'Submit';}else{echo '提交';}?>" class="submit-button"/>
                    </div>

                  </form>
                  
                </div>
      </div>
            
            
            
            
            
            
            <!-- start top button -->
            <div class="topbutton"><a href="#header"><span>Top</span></a></div>
            <!-- end top button -->
            
            
            
            <!-- start footer -->
            <div class="footer">
            © Copyright 2013 . developed by Netcube
            </div>
            <!-- end footer -->
            
            
    
    <div class="clear"></div>
    </div>
    <!-- end page -->
	
    
    
    
    
</body>
</html>
